<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>拖拽动态模糊框</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    .mohu{
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        display: none;
        position: fixed;
        top: 0;
        left: 0;
    }
    .box{
        width: 400px;
        height: 200px;
        background-color: #bdb6ec;
        display: none;
        position: absolute;
        top: 200px;
        left: 300px;
    }
</style>
<body>
    <div class="mohu"></div>
    <div class="box"></div>
    <button  class="btn">dianji</button>
</body>
<script>
    var mohu = document.querySelector('.mohu')
    var box = document.querySelector('.box')
    var btn = document.querySelector('.btn')
    
    btn.onclick = function(){
        mohu.style.display = 'block'
        box.style.display = 'block'
    }

    box.onmousedown = function(e){
        var x = e.pageX-box.offsetLeft;
        var y = e.pageY-box.offsetTop;
        console.log(x,y);


        document.onmousemove = function(e){
            box.style.left = e.pageX-x+'px'
            box.style.top = e.pageY-y+'px'
        }

        document.onmouseup = function(){
            document.onmousemove = null
        }
    }

</script>
</html>